package 数组;

/**
 * @Author Weton Li
 * @Date 2021/5/1 10:21
 */
public class 最大连续1的个数 {
    public static void main(String[] args) {
        int[] input = {1,1,0,1,1,1};
        System.out.println(method(input));
    }

    public static int method(int[] arr){
        int n = arr.length;
        int curC=0;
        int maxC=0;
        int i = 0;
        while (i < n) {
            if (arr[i] == 1) {
                curC++;
            }
            if (arr[i] == 0) {
                maxC = Math.max(curC,maxC);
                curC = 0;
            }
            i++;
        }
        maxC = Math.max(curC,maxC);
        return maxC;
    }

}
